//
//  SISSBaseVC.m
//  SISSAPP
//
//  Created by 优房网 on 2017/3/10.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSBaseViewController.h"

@interface SISSBaseViewController ()

@end

@implementation SISSBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 更改NavigationBar底部线条颜色
    UINavigationBar *navigationBar = self.navigationController.navigationBar;
    
//    [navigationBar setBackgroundImage:[ImageWithColor imageWithColor:COLOR(0xF9F9F9)] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
    [navigationBar setShadowImage:[ImageWithColor imageWithColor:[UIColor groupTableViewBackgroundColor]]];
    [self noDataShowWithMessage:@"暂无数据！！！"];
    [self setupNavigationItems];
    [self setupSubviews];
    [self initConstraint];
}

- (void)setupSubviews {
    [self.view setBackgroundColor:[UIColor whiteColor]];
    
    
}


- (void)setupNavigationItems {

}

- (void)initConstraint {
    
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    //将键盘缩回去,让控制器所管理的UIView结束编辑
    [self.view endEditing:YES];
}

- (void)noDataShowWithMessage:(NSString *)message {
    UIView *bgView = [[UIView alloc] initWithFrame:self.view.bounds];
    bgView.backgroundColor = UIColor.whiteColor;
    
    NSString *imageName = [SISSPublicSingleton shared].isNoNetwork ? @"网络" : @"空白";
    NSString *textStr = [SISSPublicSingleton shared].isNoNetwork ? @"糟糕~网络开小差了" : message;
    
    UIImageView *bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]];
    [bgImageView sizeToFit];
    [bgView addSubview:bgImageView];
    
    UILabel *tipLabel = [[UILabel alloc] init];
    tipLabel.font = [UIFont systemFontOfSize:12];
    tipLabel.textColor = COLOR(0x8998A5);
    tipLabel.text = textStr;
    [bgView addSubview:tipLabel];
    
    [bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(bgView);
        make.centerY.equalTo(bgView).offset(- 44);
    }];
    
    [tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bgImageView.mas_bottom).offset(16);
        make.centerX.equalTo(bgView);
    }];
    
    [self.view addSubview:bgView];
    self.noDataShowView = bgView;
    self.noDataShowView.hidden = YES;
}

@end
